//
//  MineOrderContectTableViewCell.m
//  MJApp
//
//  Created by wangliang on 15/3/29.
//  Copyright (c) 2015年 wangliang. All rights reserved.
//

#import "MineOrderContectTableViewCell.h"

@interface MineOrderContectTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *picImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *numLabel;
@property (weak, nonatomic) IBOutlet UILabel *stateLabel;
@property (weak, nonatomic) IBOutlet UILabel *allNumLabel;
@property (weak, nonatomic) IBOutlet UILabel *allPriceLabel;

@end

@implementation MineOrderContectTableViewCell

+ (instancetype)initWithTableView:(UITableView *)tableView {
    
    static NSString *cellID = @"MineOrderContectTableViewCell";
    MineOrderContectTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        
        cell =  WL_XIB(@"MineOrderContectTableViewCell");
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.cellHigh = CGRectGetHeight(cell.frame);
    return cell;
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setInfoDic:(NSDictionary *)infoDic {
    
    _infoDic = infoDic;
    
    CGFloat allPrice = [infoDic[@"totalPrice"] floatValue];
    self.allPriceLabel.text = [NSString stringWithFormat:@"¥%0.2f",allPrice];
    self.stateLabel.text = infoDic[@"status_msg"];
    self.nameLabel.text = [infoDic[@"cname"] isKindOfClass:[NSNull class]] ? @"" : infoDic[@"cname"];
    self.allNumLabel.text = [NSString stringWithFormat:@"共%@件商品",infoDic[@"num"]];
    
    NSString *oriPriceStr = [infoDic[@"primePrice"] isKindOfClass:[NSNull class]] ? @"" : infoDic[@"primePrice"];
    CGFloat oriPriceF = [oriPriceStr floatValue];
    self.priceLabel.text = [NSString stringWithFormat:@"¥%0.2f",oriPriceF];
    
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",kUrl,infoDic[@"image"]];
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:urlStr]];
}

@end
